package com.example.flower_shop.controller.usr;

import com.example.flower_shop.common.PageResult;
import com.example.flower_shop.service.usr.UserCollectService;
import com.example.flower_shop.vo.collect.CollectPageReq;
import com.example.flower_shop.vo.collect.CollectReq;
import com.example.flower_shop.vo.collect.CollectRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import org.springframework.web.bind.annotation.*;

@Tag(name = "用户收藏操作")
@RestController
@RequestMapping("/api/usr/collect")
public class UsrCollectController {


    @Resource
    private UserCollectService collectService;

    @GetMapping("")
    @Operation(summary = "获取当前用户收藏列表", method = "GET")
    public PageResult<CollectRespVO> getCollectList(@Valid CollectPageReq req) {
        return collectService.getCollectList(req);
    }

    @PostMapping("")
    @Operation(summary = "添加收藏", method = "POST")
    public void addCollect(@Valid CollectReq req) {
        collectService.addCollect(req);
    }

    @DeleteMapping("/{id}")
    @Operation(summary = "取消收藏", method = "DELETE", parameters = {
            @Parameter(name = "id", description = "收藏列表id或商品id", required = true
                    , in = ParameterIn.PATH)
    })
    public void deleteCollect(@PathVariable("id") Long id) {
        collectService.deleteCollect(id);
    }
}
